package listeners;

import utilities.Workbench;
import android.graphics.Color;
import android.view.View;
import android.view.View.OnClickListener;
import code.theMaze.TheMazeButton;

public class BlackAndWithe implements OnClickListener {

	private TheMazeButton clickedButton;
	private Workbench workbench;

	public BlackAndWithe(TheMazeButton bu, Workbench wb) {

		this.clickedButton = bu;
		this.workbench = wb;
	}

	@Override
	public void onClick(View v) {
		
		if (!(clickedButton.getColor() == Color.BLACK)) {
				clickedButton.setBackgroundColor(Color.BLACK);
				clickedButton.setColor(Color.BLACK);
				this.workbench.getMemory()[clickedButton.getX()][clickedButton.getY()] = Color.BLACK;
		}else if(clickedButton.getColor() == Color.BLACK){
			clickedButton.setColor(workbench.getTheChosenColor());
			clickedButton.setBackgroundColor(workbench.getTheChosenColor());
			this.workbench.getMemory()[clickedButton.getX()][clickedButton.getY()] = workbench.getTheChosenColor();
		}
		
		workbench.getConsole().setTextColor(Color.BLACK);
		workbench.getConsole().setText("************"+ clickedButton.getColor() + " x " + clickedButton.getX()+" y "+ clickedButton.getY());
	}
}
